﻿<!--
   Copyright (c) 2011, Microsoft Corporation
  
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
  
	   http://www.apache.org/licenses/LICENSE-2.0
  
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:vc="clr-namespace:Microsoft.Samples.ServiceBus.WindowsPhoneChat.ValueConverters"
	xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
	mc:Ignorable="d"
	x:Class="Microsoft.Samples.ServiceBus.WindowsPhoneChat.ChatTopicListControl"
	d:DesignWidth="468" d:DesignHeight="768">
	
	<UserControl.Resources>
		<vc:BoolToBrushValueConverter x:Key="SubscriptionStateToStarFillConverter" BrushWhenFalse="#00000000" BrushWhenTrue="{StaticResource PhoneForegroundBrush}"/>

		<DataTemplate x:Key="ChatTopicItemTemplate">
			<Button Click="OnTopicClicked" Style="{StaticResource EmptyButtonStyle}" Padding="0" BorderThickness="0" HorizontalContentAlignment="Stretch" Margin="12">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
						<ColumnDefinition Width="Auto"/>
					</Grid.ColumnDefinitions>
					<Button Click="OnSubscribeClicked" Style="{StaticResource EmptyButtonStyle}" BorderThickness="0" Padding="0">
						<Path Fill="{Binding IsSubscribed, Converter={StaticResource SubscriptionStateToStarFillConverter}}"  Stroke="{StaticResource PhoneForegroundBrush}" StrokeThickness="3" Stretch="Fill" Data="F1 M 6.5,32.3707L 10.5172,20.0063L 0,12.3654L 12.9333,12.3654L 17.0173,3.05176e-005L 21.0987,12.3654L 34.036,12.3654L 23.5184,20.0066L 27.536,32.3707L 17.018,24.7292L 6.5,32.3707 Z " Width="48" Height="48"/>
					</Button>
					<TextBlock Text="{Binding Name}" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="{StaticResource PhoneFontSizeLarge}" FontFamily="{StaticResource PhoneFontFamilyNormal}" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="1" Margin="12,0"/>
					<Button Click="OnDeleteTopicClicked" Style="{StaticResource EmptyButtonStyle}" Grid.Column="2" Padding="0">
						<Image Source="Resources/Delete.png" VerticalAlignment="Center" HorizontalAlignment="Right"/>
					</Button>
				</Grid>
			</Button>
		</DataTemplate>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" Background="Transparent">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition/>
		</Grid.RowDefinitions>

		<!--ContentPanel - place additional content here-->
	<!--TitlePanel contains the name of the application and page title-->
		<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="0,17,0,0" d:LayoutOverrides="GridBox">
			<TextBlock x:Name="ApplicationTitle" Text="Windows Azure Service Bus" Style="{StaticResource PhoneTextNormalStyle}"/>
			<TextBlock x:Name="PageTitle" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Text="topics"/>
		</StackPanel>
		<ScrollViewer Margin="0,0,12,0" Grid.Row="1" >
			<ItemsControl ItemsSource="{Binding Items}" ItemTemplate="{StaticResource ChatTopicItemTemplate}" Padding="0,24,0,0" Height="635" Width="456" />

		</ScrollViewer>

	</Grid>
</UserControl>